package com.itheima.Mapper;

import com.itheima.pojo.Member;
import com.itheima.pojo.Order;
import com.itheima.pojo.OrderSetting;
import com.itheima.pojo.SubmitOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.Date;

@Mapper
public interface OrderDao {
    //根据电话号码查询会员信息
    @Select("select * from chuanzhi.t_member where phoneNumber=#{phoneNumber}")
    Member selectByPhoneNumber(String phoneNumber);

    //根据日期查询预约信息
    @Select("select * from chuanzhi.t_ordersetting where orderDate=#{orderDate}")
    OrderSetting selectByDate(LocalDate orderDate);

    //新增会员

    void addMember(Member member);


    //根据会员id查询是否在同一天预约了同一个套餐
    @Select("select member_id ,orderDate,setmeal_id,COUNT(*) from chuanzhi.t_order where member_id=#{id} group by member_id,orderDate,setmeal_id having COUNT(*)=1")
    Order selectByMemberIdAndSetmealId(Integer id);

    void addOrder(SubmitOrder submitOrder);
}
